

#ifndef UCDB_XRECORD_H
#define UCDB_XRECORD_H

#include "zAdAChar.h"
#include "zdbmain.h"

#define UCDB_XRECORD_CLASS          UCRX_T("AcDbXrecord")
#define UCDB_XRECORD_ITERATOR_CLASS UCRX_T("AcDbXrecordClass")

#pragma pack(push, 8)

class UcDbXrecord: public UcDbObject
{
public:
    UCDB_DECLARE_MEMBERS(UcDbXrecord);
    UcDbXrecord();
    virtual ~UcDbXrecord();

    Ucad::ErrorStatus rbChain(resbuf** ppRb, UcDbDatabase* auxDb = NULL) const;
    Ucad::ErrorStatus setFromRbChain(const resbuf& pRb,
                                             UcDbDatabase* auxDb = NULL);

    bool              isXlateReferences() const;
    void              setXlateReferences(bool translate);

    virtual Ucad::ErrorStatus subClose();
    virtual Ucad::ErrorStatus dwgInFields(UcDbDwgFiler* filer);
    virtual Ucad::ErrorStatus dwgOutFields(UcDbDwgFiler* filer) const;
    virtual Ucad::ErrorStatus dxfInFields(UcDbDxfFiler* filer);
    virtual Ucad::ErrorStatus dxfOutFields(UcDbDxfFiler* filer) const;

    virtual UcDb::DuplicateRecordCloning mergeStyle() const;
    virtual void  setMergeStyle(UcDb::DuplicateRecordCloning style);

    virtual Ucad::ErrorStatus getClassID(CLSID* pClsid) const;
};

class UcDbImpXrecordIterator;

class UcDbXrecordIterator: public UcRxObject
{
public:
    UCRX_DECLARE_MEMBERS(UcDbXrecordIterator);
 
    UcDbXrecordIterator(const UcDbXrecord* pXrecord);
    virtual ~UcDbXrecordIterator();

    void              start();
    bool              done() const;
    Ucad::ErrorStatus next();
    int               curRestype() const;
    Ucad::ErrorStatus getCurResbuf(resbuf& outItem, UcDbDatabase* db) const;

protected:
    UcDbXrecordIterator() {};
private:
    friend class UcDbXrecord;
    friend class UcDbImpXrecord;
    UcDbImpXrecordIterator* mpImpIter;
};

#pragma pack(pop)

#endif
